<div class="panel panel-default">
  <div class="panel-heading"><?= empty($data) ? '添加文章' : '编辑文章' ?></div>
  <div class="panel-body">
    <form action="<?=Yii::app()->createUrl('teacher/post_article',array('lesson_id'=>$lesson->lesson_id))?>" method="post" class="form-horizontal">
      <fieldset>
        <?php 
        if(!empty($data)){
          echo CHtml::hiddenField('article_id',$data->article_id);
        }else{
          echo CHtml::hiddenField('lesson_id',$lesson->lesson_id);
        }
        ?>
        <div class="form-group">
          <label for="title" class="control-label col-md-1">标题</label>
          <div class="col-md-6">
            <input type="text" name="title" id="title" maxlength="40" required="" value="<?=CHtml::encode($data->title)?>" autofocus=""
                   placeholder="请输入文章名称" class="form-control">
          </div>
        </div>
        <div class="form-group">
          <label for="title" class="control-label col-md-1">内容</label>
          <div class="col-md-6">
            <script type="text/plain" id="editor" name="content" style="width:100%;height:500px"><?=CHtml::decode($data->content)?></script>
          </div>
        </div>
        <div class="form-group">
          <div class="col-md-2 col-md-offset-1">
            <button type="submit" class="btn btn-primary btn-block">提交</button>
          </div>
        </div>
      </fieldset>
    </form>
  </div>
</div>
<script>
  $(function(){
    initEditor('editor');
  });
</script>